<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'分配监理'}"></three-title>
    <div class="layerRtb-scroll">
        <table class="uiTable j_outerHeight">
            <thead>
                <tr>
                    <th width="30%">序号</th>
                    <th width="30%">监理</th>
                    <th width="30%">电话</th>
                    <th>选择</th>
                </tr>
            </thead>
        </table>
        <div class="scroll-content thinScroll thinScroll-table"  v-scrollHeight="36">
            <table class="uiTable uiTable-striped uiTable-hover">
                <tbody>
                    <tr v-for="(item,index) in superList" :key="index">
                        <td width="30%">{{index + 1}}</td>
                        <td width="30%">{{item.u_xingming}}</td>
                        <td width="30%">{{item.u_shouji}}</td>
                        <td class="tx-center">
                            <el-radio v-model="superName" :label="item.u_kahao">{{selectName}}</el-radio>
                        </td>
                    </tr>
                    <tr v-if="superList.length === 0">
                        <td class="tx-center">暂无数据</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                 <div class="tx-center">
                    <input type="button" class="uiBtn-normal uiBtn-blue" value="确定" @click="superSubmit()">
                </div>
            </div>
        </div>
    </div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { chooseSupervision } from '../../Resources/Api/index'
export default {
    data () {
        return {
            selectName: null,
            superName: '', // 监理选择
            superList: [], // 监理列表
            loginList: []
        }
    },
    created () {
        this.superList = this.$route.query.superList
        this.loginList = this.$route.query.loginList
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    methods: {
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        },
        select () {
            console.log(this.radio)
        },
        // 监理提交
        superSubmit () {
            if (this.superName === '') {
                this.$message({
                    type: 'info',
                    message: '请选择监理'
                })
            } else {
                const current = this.superList.filter((item) => { return item.u_kahao === this.superName })
                let parms = {
                    orderNo: this.leftInfo.orderno,
                    supervisorUserno: this.superName,
                    supervisorUsername: current[0].u_xingming
                }
                chooseSupervision(parms).then((result) => {
                    this.$message({
                        type: 'success',
                        message: '监理选择成功'
                    })
                    const currentLeftInfo = this.leftInfo
                    this.setLeftData({
                        ...currentLeftInfo,
                        supervisor_username: current[0].u_xingming
                    })
                }).catch((error) => {
                    console.log(error)
                })
            }
        }
    },
    watch: {
        $route () {
            this.loginList = this.$route.query.loginList
            this.superList = this.$route.query.superList
        }
    }
}
</script>
